package CS4310.csueb.visual;

import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;

import CS4310.csueb.items.Item;

public class InventoryItem extends JPanel
{
	private JLabel itemName;
	private JButton equipItem;
	
	public InventoryItem(Item i)
	{
		itemName = new JLabel(i.toString());
		equipItem = new JButton("equip");
		equipItem.setPreferredSize(new Dimension(70, 20));
		
		this.setPreferredSize(new Dimension(200, 25));
		this.setLayout(new FlowLayout(FlowLayout.LEFT));
		this.add(itemName);
		this.add(equipItem);
	}
	
	public void addActionListener(ActionListener arg0)
	{
		equipItem.addActionListener(arg0);
		equipItem.setActionCommand(itemName.getText());
	}
	
	/**
	 * Retrieves the item to be equipped to the hero
	 * @return the item that has been selected for equipping
	 */
	public String getItemTrigger()
	{
		return itemName.getText();
	}
}
